package com.spyz.hdfs_api;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.net.URI;

public class P5_Hdfs_api_mv_2 {
    public static void main(String[] args) throws Exception {

        URI uri = new URI("hdfs://master:8020");

        Configuration conf = new Configuration();
        conf.set("dfs.replication","2");

        String user = "root";

        FileSystem fs = FileSystem.get(uri, conf,user);


        // 文件移动并更改名称
        fs.rename(
                new Path("/hdfs_api/word_rename.txt"),
                new Path("/input/my_rename.txt")
        );
        fs.close();
    }
}
